Just a cleanup in preparation for future work.
Closes: #575
Approved by: giuseppe
#include "libglnx.h"
#include "ostree-gpg-verifier.h"
+#include "ot-gpg-utils.h"
#include "ostree-gpg-verify-result-private.h"
#include "otutil.h"
GCancellable *cancellable,
GError **error)
{
- gpgme_ctx_t gpg_ctx = NULL;
gpgme_error_t gpg_error = 0;
- gpgme_data_t data_buffer = NULL;
- gpgme_data_t signature_buffer = NULL;
+ ot_auto_gpgme_data gpgme_data_t data_buffer = NULL;
+ ot_auto_gpgme_data gpgme_data_t signature_buffer = NULL;
g_autofree char *tmp_dir = NULL;
g_autoptr(GOutputStream) target_stream = NULL;
OstreeGpgVerifyResult *result = NULL;
success = TRUE;
out:
-
- if (gpg_ctx != NULL)
- gpgme_release (gpg_ctx);
- if (data_buffer != NULL)
- gpgme_data_release (data_buffer);
- if (signature_buffer != NULL)
- gpgme_data_release (signature_buffer);
-
if (success)
{
/* Keep the temporary directory around for the life of the result
GError **error)
{
OstreeRemote *remote;
- gpgme_ctx_t source_context = NULL;
- gpgme_ctx_t target_context = NULL;
- gpgme_data_t data_buffer = NULL;
+ ot_auto_gpgme_ctx gpgme_ctx_t source_context = NULL;
+ ot_auto_gpgme_ctx gpgme_ctx_t target_context = NULL;
+ ot_auto_gpgme_data gpgme_data_t data_buffer = NULL;
gpgme_import_result_t import_result;
gpgme_import_status_t import_status;
const char *tmp_dir = NULL;
if (target_tmp_dir != NULL)
(void) glnx_shutil_rm_rf_at (AT_FDCWD, target_tmp_dir, NULL, NULL);
- if (source_context != NULL)
- gpgme_release (source_context);
-
- if (target_context != NULL)
- gpgme_release (target_context);
-
- if (data_buffer != NULL)
- gpgme_data_release (data_buffer);
-
g_prefix_error (error, "GPG: ");
return ret;
#include <gpgme.h>
#include <gio/gio.h>
+#include "libglnx.h"
G_BEGIN_DECLS
+GLNX_DEFINE_CLEANUP_FUNCTION0(gpgme_data_t, ot_cleanup_gpgme_data, gpgme_data_release)
+#define ot_auto_gpgme_data __attribute__((cleanup(ot_cleanup_gpgme_data)))
+GLNX_DEFINE_CLEANUP_FUNCTION0(gpgme_ctx_t, ot_cleanup_gpgme_ctx, gpgme_release)
+#define ot_auto_gpgme_ctx __attribute__((cleanup(ot_cleanup_gpgme_ctx)))
+
void ot_gpgme_error_to_gio_error (gpgme_error_t gpg_error, GError **error);
gboolean ot_gpgme_ctx_tmp_home_dir (gpgme_ctx_t gpgme_ctx,